package com.yinhai.adapter;

import java.util.ArrayList;
import java.util.List;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;

import com.androidquery.AQuery;
import com.lz.util.Utils;
import com.yinhai.activity.R;
import com.yinhai.constant.UrlConstant;

public class SettingListAdapter extends BaseAdapter {
	private ArrayList<List<String>> dataList;
	private LayoutInflater layoutInflater;
	private Context context;
	
	public SettingListAdapter(Context context){
		this.context=context;
		this.dataList=new ArrayList<List<String>>();
		this.layoutInflater=LayoutInflater.from(this.context);
	}
	
	public void addItem(List<String> item){
		dataList.add(item);
	}
	
	public void clear(){
		dataList.clear();
	}
	
	@Override
	public int getCount() {
		return dataList.size();
	}

	@Override
	public List<String> getItem(int position) {
		return dataList.get(position);
	}

	@Override
	public long getItemId(int position) {
		return position;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		if (convertView==null) {
			convertView = layoutInflater.inflate(R.layout.setting_list_item, null);
		}
		AQuery aq = new AQuery(convertView);
		List<String> list = getItem(position);
		aq.id(R.id.setting_name).text(list.get(0));
		aq.id(R.id.setting_gs).text(list.get(1));
		aq.id(R.id.contact_list1).image(UrlConstant.LOCAL_URI+"getPhoto?phone="+list.get(2),Utils.getImageOptions(context,R.drawable.tel_photo, Utils.IsImgSize));
		
		return convertView;
	}
}
